<?php
if ($_POST['modified'] == 'true') {
  update_option('wppp_automate', $_POST['wppp_automate']);
  update_option('wppp_rel', $_POST['wppp_rel']);
  update_option('wppp_speed', $_POST['wppp_speed']);
  update_option('wppp_padding', $_POST['wppp_padding']);
  update_option('wppp_opacity', $_POST['wppp_opacity']);
  update_option('wppp_title', $_POST['wppp_title']);
  update_option('wppp_resize', $_POST['wppp_resize']);
  update_option('wppp_counterlabel', $_POST['wppp_counterlabel']);
}
?>

<div class="wrap">
  <h2><?php _e('WP-prettyPhoto Options', 'prettyphoto') ?></h2>
  <form name="form1" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>&updated=true">
  <input type="hidden" name="modified" value="true" />
  <table width="100%" cellspacing="2" cellpadding="5" class="form-table">

  <!-- wpp_automate -->
  <tr valign="baseline">
    <th scope="row"><?php _e('Auto-prettyfy image links', 'prettyphoto') ?></th> 
    <td>
    <?php
    $wppp_automate = get_option('wppp_automate');
    $checked = $wppp_automate == 1? "checked=\"checked\" " : ' ';
    echo "\n<input type=\"checkbox\" name=\"wppp_automate\" value=\"1\" $checked/>\n";
    ?>
    <p><small><?php _e('Let the plugin add necessary html to image links', 'prettyphoto') ?></small></p>
    </td>
  </tr>
  
  <!-- wpp_rel -->
  <tr valign="baseline">
  <th scope="row"><?php _e('Rel value', 'prettyphoto') ?></th> 
    <td>
    <?php
    $wppp_rel= get_option('wppp_rel');
    echo "<input type='text' name='wppp_rel' value='".$wppp_rel."'></input>";
    ?>
    <p><small><?php _e('prettyPhoto will hook itself on rel attributes in links. You can customize that string here.', 'prettyphoto') ?></small></p>
    </td>
    </tr>
  
  <!-- wpp_speed -->
  <tr valign="baseline">
  <th scope="row"><?php _e('Animation speed', 'prettyphoto') ?></th> 
    <td>
    <?php
    $wppp_speed = get_option('wppp_speed');
    $speeds = array('fast','slow','normal');
    echo "<select name='wppp_speed'>";
    foreach ($speeds as $speed) {
      echo ($wppp_speed == $speed)? "<option value='$speed' selected='selected'>$speed</option>" : "<option value='$speed'>$speed</option>";
    }
    echo '</select>';
    ?>
    <p><small><?php _e('The animation speed', 'prettyphoto') ?></small></p>
    </td>
  </tr>
    
   <!-- wpp_padding -->
  <tr valign="baseline">
  <th scope="row"><?php _e('Padding', 'prettyphoto') ?></th> 
    <td>
    <?php
    $wppp_padding = get_option('wppp_padding');
    echo "<input type='text' name='wppp_padding' value='".$wppp_padding."' maxlength='3'></input>";
    ?>
    <p><small><?php _e('Padding for each side of the picture', 'prettyphoto') ?></small></p>
    </td>
  </tr>
  
  <!-- wpp_opacity -->
  <tr valign="baseline">
  <th scope="row"><?php _e('Opacity', 'prettyphoto') ?></th> 
    <td>
    <?php
    $wppp_opacity = get_option('wppp_opacity');
    echo "<input type='text' name='wppp_opacity' value='".$wppp_opacity."' maxlength='3'></input>";
    ?>
    <p><small><?php _e('Value betwee 0 and 1', 'prettyphoto') ?></small></p>
    </td>
  </tr>
  
  <!-- wpp_title -->
  <tr valign="baseline">
  <th scope="row"><?php _e('Show title', 'prettyphoto') ?></th> 
    <td>
    <?php
    $wppp_title = get_option('wppp_title');
    echo "\n<input type=\"checkbox\" name=\"wppp_title\" value=\"true\" $checked/>\n";
    ?> 
    <p><small><?php _e('Display title', 'prettyphoto') ?></small></p>
    </td>
  </tr>
  
  <!-- wpp_resize -->
  <tr valign="baseline">
  <th scope="row"><?php _e('Allow resize', 'prettyphoto') ?></th> 
    <td>
    <?php
    $wppp_resize = get_option('wppp_resize');
    $checked = $wppp_resize == 'true'? "checked=\"checked\" " : ' ';
    echo "\n<input type=\"checkbox\" name=\"wppp_resize\" value=\"true\" $checked/>\n";
    ?>
    <p><small><?php _e('Allow container resize', 'prettyphoto') ?></small></p>
    </td>
  </tr>

  <!-- wpp_counterlabel -->
  <tr valign="baseline">
  <th scope="row"><?php _e('Counter Separator Label', 'prettyphoto') ?></th> 
    <td>
    <?php
    $wppp_counterlabel = get_option('wppp_counterlabel');
    echo "<input type='text' name='wppp_counterlabel' value='".$wppp_counterlabel."'></input>";
    ?>
    <p><small><?php _e('The separator for the gallery counter 1 <em><strong>of</strong></em> 2', 'prettyphoto') ?></small></p>
    </td>
  </tr>
</table>

  <p class="submit">
    <input type="submit" name="Submit" value="<?php _e('Save Changes', 'prettyphoto') ?>" />
  </p>
  </form>
</div>